1
/****************************** Module Header ******************************\
2 * Module Name: PersonTableStorageContext.cs
3 * Project: CSAzureTableStorageWCFDS
4 * Copyright (c) Microsoft Corporation.
6 * This is the table storage context.
7 * Do not confuse it with PersonDataServiceContext (the WCF Data Service object context).
9 * This source is subject to the Microsoft Public License.
10 * See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 * All other rights reserved.
13 * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
14 * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
16 \***************************************************************************/
19 using Microsoft
.WindowsAzure
;
20 using Microsoft
.WindowsAzure
.StorageClient
;
22 namespace WebRole
.Entities
25 /// This is the table storage context.
26 /// Do not confuse it with PersonDataServiceContext (the WCF Data Service object context).
27 /// Table storage contexts should derive from TableServiceContext.
29 public class PersonTableStorageContext
: TableServiceContext
31 private static CloudStorageAccount account
;
32 public static string TableName
= "Person";
34 static PersonTableStorageContext()
36 account
= CloudStorageAccount
.FromConfigurationSetting("DataConnectionString");
37 CloudTableClient tableClient
= new CloudTableClient(account
.TableEndpoint
.AbsoluteUri
, account
.Credentials
);
38 tableClient
.CreateTableIfNotExist(TableName
);
41 public PersonTableStorageContext()
42 : base(account
.TableEndpoint
.AbsoluteUri
, account
.Credentials
)
46 public IQueryable
<Person
> Person
48 get { return this.CreateQuery<Person>(TableName); }